package news.dao;

import news.example.Publish;
import news.util.BaseDao;

/**
 * @author JiangJ
 * @date 2022/3/4 15:00
 */
public class AddPublishImpl implements IAddPublishDao{
    BaseDao baseDao=new BaseDao();
    @Override
    public void addNews(String theme,String title,String username,String digest,String content) {
        try {
            baseDao.openDB();
            String sql = "INSERT INTO news_publish (theme,title,username,digest,content) VALUE (?,?,?,?,?)";
            baseDao.ps = baseDao.conn.prepareStatement(sql);
            baseDao.ps.setString(1, theme);
            baseDao.ps.setString(2, title);
            baseDao.ps.setString(3, username);
            baseDao.ps.setString(4, digest);
            baseDao.ps.setString(5, content);
            baseDao.ps.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void addNewsRes(String respath) {
        try {
            Publish publish = new Publish();
            baseDao.openDB();
            String sql = "INSERT INTO news_res (respath) VALUE (?)";
            baseDao.ps = baseDao.conn.prepareStatement(sql);
            baseDao.ps.setString(1, respath);
//            baseDao.ps.setInt(2, newsid);
//            baseDao.ps.setString(2, type);
            baseDao.ps.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
